﻿using NUnit.Framework;
using TfsWrapper.Commands;

namespace TfsWrapper.Tests
{
    public class FindMentionsByChangesetCommandTest : TfsTest
    {
        private SpyWriter writer;
        private FindMentionsByChangesetCommand target;

        [SetUp]
        public void Setup()
        {
            writer = new SpyWriter();
            target = new FindMentionsByChangesetCommand(new IssueMentionPrinter(writer));
        }

        [Test]
        public void ValidChangesetId()
        {
            target.Execute(Tfs, new[] { "8" });

            Assert.AreEqual("2", writer.NextLine);
            StringAssert.AreEqualIgnoringCase("https://simoneb.visualstudio.com/DefaultCollection/IssueTrackingSandbox/_workitems/edit/2", writer.NextLine);
        }

        [Test]
        public void InvalidChangesetId()
        {
            target.Execute(Tfs, new[] { "abc" });

            Assert.IsEmpty(writer.Written);
        }

        [Test]
        public void NonExistingChangesetId()
        {
            target.Execute(Tfs, new[] { "404" });

            Assert.IsEmpty(writer.Written);
        }
    }
}
